<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

</body>
<script src="../../05jQuery/jquery-3.2.1.js"></script>
<script>
  function request(type, url, data) {
    return new Promise((resolve, reject) => {
      $.ajax({
        type,
        url,
        data,
        success: res => {
          resolve(res)
        },
        error: err => {
          reject(err)
        }
      })
    })
  }

  async function fn() {
    // 先拿到城市id
    console.log(0)
    let res = await request('get', "https://geoapi.qweather.com/v2/city/lookup",
      { location: "青岛", key: "c494e264764449f7b4f6bf742276d7f9" })
    console.log(1)
    console.log(res)
    console.log(2) //0 1 res 2
    // 城市实时天气
    let wea = await request('get', "https://geoapi.qweather.com/v2/city/lookup",
      { location: res.location[0].id, key: "c494e264764449f7b4f6bf742276d7f9" })
    console.log(wea)
  }
  fn()
</script>

</html>